package com.itheima.stream;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Anomaly
 * @date 2023/2/6 17:04
 */
public class StreamDemo4 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        Collections.addAll(list, "张三丰", "张无忌", "周芷若", "赵敏", "张强");
        System.out.println(list);
        Stream<String> stream = list.stream().filter(s -> s.startsWith("张"));

        //System.out.println(stream.toList());
        //注意流只能使用一次
        List<String> collect = stream.collect(Collectors.toList());
        System.out.println("collect = " + collect);
    }
}
